﻿using System.Collections.Generic;
using System.IO;
using System.Linq;
using ImageProcessingLib.Configuration;

namespace ImageProcessingLib
{
    public static class ImageHelper
    {
        public static List<FileInfo> GetLatestImageFiles(string path, int count, List<string> supportedExtensions)
        {
            if (!Directory.Exists(path))
                throw new DirectoryNotFoundException("目录不存在");

            return Directory.GetFiles(path, "*.*")
                .Where(f => supportedExtensions.Contains(Path.GetExtension(f).ToLower()))
                .Select(f => new FileInfo(f))
                .OrderByDescending(fi => fi.LastWriteTime)
                .Take(count)
                .ToList();
        }
    }
}